package by.semerikov.generator;
import by.semerikov.generator.properties.Properties;
import by.semerikov.parts.Log;

public class AccessLog implements IGeneratable {
	private Properties allProp = new Properties();
	IpGenerator ip;
	DateGenerator date;
	RequestLineGenerator requestLine;
	CodeGenerator code;
	SizeReturnedObjectGenerator sizereturn;
	TimeOffsetGenerator timeOffset;
	HttpVersionGenerator httpVersion;
	

	public AccessLog(Properties prop)
	{
		allProp = prop;
		ip = new IpGenerator();
		date = new DateGenerator();
		requestLine = new RequestLineGenerator();
		code = new CodeGenerator();
		sizereturn = new SizeReturnedObjectGenerator();
		timeOffset = new TimeOffsetGenerator();
		httpVersion = new HttpVersionGenerator();
	}
	
	@Override
	public Log generate() {
		Log resultLog = new Log();
		resultLog.setIp(ip.generate(allProp.getIpProperty()));
		resultLog.setDate(date.generate(allProp.getDataProperty()));
		resultLog.setRequestLine(requestLine.generate(allProp.getRequestProperty()));
		resultLog.setCode( code.generate(allProp.getCodeProperty()));
		resultLog.setSizeReturned( sizereturn.generate(allProp.getSizeReturnProperty()));
		resultLog.setTimeOffset(timeOffset.generate(allProp.getTimeOffsetProperty()));
		resultLog.setHttpVersion(httpVersion.generate(allProp.getHttpVersionProperty()));
		return resultLog;
	}

}
